<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="author" content="wangbo">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>from组件</title>
</head>

<body>
    <div id="app">

    </div>
    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script src="../js/prop-types.js"></script>
    <script src="../js/babel.min.js"></script>
    <script type="text/babel">
        class Myform extends React.Component {
            state = { myinpt: "123", gd: 1,sel:"打代码" }
            chg = (event) => { }
            chgr = (event) => {
                if (event.target.value == '男') {
                    this.setState({ gd: 2 })
                } else {
                    this.setState({ gd: 1 })
                }
            }
            chgs = (event) => {
                console.log(event.target.value)
                this.setState({ sel: event.target.value })
             }
            render() {
                return (
                    <form action="" method="get">
                        用户名<input type="text" ref={e => this.mye = e} /> <br />
                        密码 <input type="text" value={this.state.myinpt} onChange={this.chg} /> <br />
                        性别
                        <input type="radio" name="gender" id="" value='男' checked={this.state.gd == 2} onChange={this.chgr} />
                        <input type="radio" name="gender" id="" value='女' checked={this.state.gd == 1} onChange={this.chgr} /> <br />

                        <select name="" id="" value={this.state.sel}  onChange={this.chgs} >
                            <option value="睡觉">睡觉</option>
                            <option value="吃饭">吃饭</option>
                            <option value="玩手机">玩手机</option>
                            <option value="打代码" >打代码</option>
                        </select>

                        <input type="submit" value="提交" />
                    </form>
                )
            }
        }
        ReactDOM.render(<Myform />, document.getElementById('app'))
    </script>



</body>

</html>